local skel = fk.CreateSkill {
  name = "emo__jieying",
}

Fk:loadTranslationTable{
  ["emo__jieying"] = "劫营",
  [":emo__jieying"] = "当你使用的【杀】或【过河拆桥】被抵消后，你可以视为对目标距离1以内的一名角色使用另一项。",

  ["#emo__jieying-choose"] = "劫营：选择1名角色，视为对其使用【%arg】",

  ["$emo__jieying1"] = "",
  ["$emo__jieying2"] = "",
}

skel:addEffect(fk.CardEffectCancelledOut, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and
      (data.card.trueName == "slash" or data.card.trueName == "dismantlement")
      and data.to and not data.to.dead
  end,
  on_cost = function (self, event, target, player, data)
    local name = data.card.trueName == "slash" and "dismantlement" or "slash"
    local card = Fk:cloneCard(name)
    card.skillName = skel.name
    local targets = table.filter(player.room.alive_players, function (p)
      return not p:isNude() and (data.to == p or data.to:distanceTo(p) == 1)
      and player:canUseTo(card, p, {bypass_distances = true, bypass_times = true})
    end)
    if #targets == 0 then return false end
    local tos = player.room:askToChoosePlayers(player, {
      min_num = 1, max_num = 1, targets = targets, skill_name = skel.name,
      prompt = "#emo__jieying-choose:::" .. name,
    })
    if #tos > 0 then
      event:setCostData(self, {tos = tos})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    local name = data.card.trueName == "slash" and "dismantlement" or "slash"
    room:useVirtualCard(name, nil, player, to, skel.name, true)
  end,
})

return skel
